//
//  CompetionAllPersonProducetViewController.m
//  ShangHaiTuJI
//
//  Created by xiaoxiangtuji on 2017/11/3.
//  Copyright © 2017年 xiaoxiangtuji. All rights reserved.
//

#import "CompetionAllPersonProducetViewController.h"
#import "InstituSubmiteOverView.h"
#import "QQAndWechatShareView.h"
#import "AppDelegate.h"
#import "WXApi.h"
#import "UMSocialQQHandler.h"
@interface CompetionAllPersonProducetViewController ()<UIScrollViewDelegate>{
    NSInteger totalNumber;
    AppDelegate *appdelegate;
}
/*新的报名详情的页面*/
@property(nonatomic,strong)UIScrollView *scrollView;

@property(nonatomic,strong)QQAndWechatShareView *shareView;
@property(nonatomic,strong)UIView *showView;
@property(nonatomic,strong)UIView *backView;
@property(nonatomic,strong)InstituSubmiteOverView *submitView;
@property(nonatomic,copy)NSString *imgePath;
@property(nonatomic,copy)NSString *babayName;
@property(nonatomic,copy)NSString *addressStr;
@property(nonatomic,copy)NSString *productName;
@property(nonatomic,copy)NSString *phoneNumberStr;
@property(nonatomic,copy)NSString *matchName;
@property(nonatomic,copy)NSString *matchEndTime;
@property(nonatomic,copy)NSString *matchTxt;

@end

@implementation CompetionAllPersonProducetViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setShareBtn];
    [self getAllDataInformation];
    // Do any additional setup after loading the view.
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    CGFloat offset = self.scrollView.contentOffset.y;
    [self.navigationController.navigationBar
     setBackgroundImage:[self imageWithColor:[UIColor colorWithRed:255/255.0 green:201/255.0 blue:31/255.0 alpha:(offset / 64)>0.99?0.99:(offset / 64)]] forBarMetrics:UIBarMetricsDefault];
    [self.navigationController.navigationBar
     setShadowImage:[UIImage new]];
}
-(UIImage*) imageWithColor:(UIColor*) color
{
    CGRect rect=CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context, [color CGColor]);
    CGContextFillRect(context, rect);
    UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return theImage;
    
}
-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage = nil;
}
-(void)setShareBtn{
    UIButton *shareBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [shareBtn setBackgroundImage:[UIImage imageNamed:@"upProductShare"] forState:UIControlStateNormal];
    [shareBtn addTarget:self action:@selector(showShareUI) forControlEvents:UIControlEventTouchUpInside];
    shareBtn.frame = CGRectMake(WIDTH - 30, 6, 20, 20);
    UIBarButtonItem *flexSpac = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:self action:nil];
    flexSpac.width = -10;
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:shareBtn];
    self.navigationItem.rightBarButtonItems = @[flexSpac,rightItem];
}
-(void)showShareUI{
    UIView *backView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    backView.alpha = 0.5f;
    backView.backgroundColor = [UIColor blackColor];
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(removebackView:)];
    [backView addGestureRecognizer:tap];
    [[UIApplication sharedApplication].keyWindow addSubview:backView];
    _shareView = [[QQAndWechatShareView alloc] initWithFrame:CGRectMake(0, HEIGHT, WIDTH, scaleTopAndBottom(94))];
    [_shareView.QQBtn addTarget:self action:@selector(QQShare:) forControlEvents:UIControlEventTouchUpInside];
    [_shareView.WechatBtn addTarget:self action:@selector(WechatShare:) forControlEvents:UIControlEventTouchUpInside];
    [[UIApplication sharedApplication].keyWindow addSubview:_shareView];
    [UIView animateWithDuration:0.1 animations:^{
        _shareView.frame = CGRectMake(0,HEIGHT - scaleTopAndBottom(94), WIDTH, scaleTopAndBottom(94));
    }];
}
-(void)WechatShare:(UIButton *)btn{
    /** 标题
     * @note 长度不能超过512字节
     */
    // @property (nonatomic, retain) NSString *title;
    /** 描述内容
     * @note 长度不能超过1K
     */
    //@property (nonatomic, retain) NSString *description;
    /** 缩略图数据
     * @note 大小不能超过32K
     */
    //  @property (nonatomic, retain) NSData   *thumbData;
    /**
     * @note 长度不能超过64字节
     */
    // @property (nonatomic, retain) NSString *mediaTagName;
    /**
     * 多媒体数据对象，可以为WXImageObject，WXMusicObject，WXVideoObject，WXWebpageObject等。
     */
    // @property (nonatomic, retain) id        mediaObject;
    
    /*! @brief 设置消息缩略图的方法
     *
     * @param image 缩略图
     * @note 大小不能超过32K
     */
    //- (void) setThumbImage:(UIImage *)image;
    //缩略图
    UIImage *image = [UIImage imageNamed:@"LOGO4"];
    WXMediaMessage *message = [WXMediaMessage message];
    message.title = @"咱俩铁吗？铁就投我一票";
    message.description = @"我在途吉打比赛，小伙伴等待你的一票啊！多谢啦！";
    //png图片压缩成data的方法，如果是jpg就要用 UIImageJPEGRepresentation
    message.thumbData = UIImagePNGRepresentation(image);
    [message setThumbImage:image];
    WXWebpageObject *ext = [WXWebpageObject object];
    ext.webpageUrl = [NSString stringWithFormat:@"%@/h5/canvass?id=%@",ServerIp,self.matchId];
    message.mediaObject = ext;
    message.mediaTagName = @"ISOFTEN_TAG_JUMP_SHOWRANK";
    
    SendMessageToWXReq *sentMsg = [[SendMessageToWXReq alloc]init];
    sentMsg.message = message;
    sentMsg.bText = NO;
    sentMsg.scene =  WXSceneSession;
    //    //选择发送到会话(WXSceneSession)或者朋友圈(WXSceneTimeline)
    //    if (isPengyouquan) {
    //        sentMsg.scene = WXSceneTimeline;  //分享到朋友圈
    //    }else{
    //        sentMsg.scene =  WXSceneSession;  //分享到会话。
    //    }
    
    //如果我们想要监听是否成功分享，我们就要去appdelegate里面 找到他的回调方法
    // -(void) onResp:(BaseResp*)resp .我们可以自定义一个代理方法，然后把分享的结果返回回来。
    appdelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
    //添加对appdelgate的微信分享的代理
    //    appdelegate.wxDelegate = self;
    BOOL isSuccess = [WXApi sendReq:sentMsg];
}
-(void)QQShare:(UIButton *)btn{
    //创建分享消息对象
    UMSocialMessageObject *messageObject = [UMSocialMessageObject messageObject];
    
    //创建网页内容对象
    NSString* thumbURL =  @"http://www.tj698.com/resource/img/logo.png";
    UMShareWebpageObject *shareObject = [UMShareWebpageObject shareObjectWithTitle:@"咱俩铁吗？铁就投我一票" descr:@"我在途吉打比赛，小伙伴等待你的一票啊！多谢啦！" thumImage:thumbURL];
    
    //设置网页地址
    shareObject.webpageUrl = [NSString stringWithFormat:@"%@/h5/canvass?id=%@",ServerIp,self.matchId];
    //分享消息对象设置分享内容对象
    messageObject.shareObject = shareObject;
    
    //调用分享接口
    [[UMSocialManager defaultManager] shareToPlatform:UMSocialPlatformType_QQ messageObject:messageObject currentViewController:self completion:^(id data, NSError *error) {
        if (error) {
            UMSocialLogInfo(@"************Share fail with error %@*********",error);
        }else{
            if ([data isKindOfClass:[UMSocialShareResponse class]]) {
                UMSocialShareResponse *resp = data;
                //分享结果消息
                UMSocialLogInfo(@"response message is %@",resp.message);
                //第三方原始返回的数据
                UMSocialLogInfo(@"response originalResponse data is %@",resp.originalResponse);
                
            }else{
                UMSocialLogInfo(@"response data is %@",data);
            }
        }
    }];
    
}
-(void)removebackView:(UITapGestureRecognizer *)tap{
    
    [UIView animateWithDuration:0.1 animations:^{
        UIView *view = tap.view;
        [view removeFromSuperview];
        [_shareView removeFromSuperview];
    }];
}
/**
 创建新的页面
 */
-(void)createNewPage{
    self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
    self.scrollView.delegate = self;
    self.scrollView.showsVerticalScrollIndicator = NO;
    [self.view addSubview:self.scrollView];
    self.scrollView.contentSize = CGSizeMake(WIDTH, scaleTopAndBottom(870));
    UIView *faterVeiw = [[UIView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, scaleTopAndBottom(870))];
    faterVeiw.backgroundColor = COLOR_HEX(0xf4f5f6);
    [self.scrollView addSubview:faterVeiw];
    UIView *topView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, scaleTopAndBottom(275))];
    [faterVeiw addSubview:topView];
    topView.backgroundColor  = COLOR_HEX(0xFFC91F);
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:topView.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(18, 18)];
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskLayer.frame = topView.bounds;
    maskLayer.path = maskPath.CGPath;
    topView.layer.mask = maskLayer;
    
//    UIImageView *overImageView = [[UIImageView alloc] init];
//    overImageView.image = [UIImage imageNamed:@"图层15"];
//    [topView addSubview:overImageView];
//    [overImageView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(topView.mas_top).offset(64);
//        make.centerX.equalTo(topView.mas_centerX);
//        make.size.mas_equalTo(CGSizeMake(scaleLeftAndRight(37), scaleTopAndBottom(37)));
//    }];
    UILabel *titleLabel = [[UILabel alloc] init];
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.text = @"参赛成功！ 距离比赛结束还有";
    titleLabel.font = [UIFont fontWithName:@"PingFangSC-Medium" size:18];
    if (WIDTH > 375.f) {
        titleLabel.font = [UIFont fontWithName:@"PingFangSC-Medium" size:27];
    }
    if (WIDTH < 375.f) {
        titleLabel.font = [UIFont fontWithName:@"PingFangSC-Medium" size:12];
    }
    titleLabel.textColor = [UIColor whiteColor];
    [topView addSubview:titleLabel];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(topView.mas_centerX);
        make.top.equalTo(topView.mas_top).offset(64);
        make.width.mas_equalTo(WIDTH);
        make.height.mas_equalTo(scaleTopAndBottom(20));
    }];
    UILabel *timeLabel = [[UILabel alloc] init];
    timeLabel.textColor = [UIColor whiteColor];
    timeLabel.textAlignment = NSTextAlignmentCenter;
    timeLabel.font = [UIFont systemFontOfSize:15];
//    timeLabel.text = @"30天14小时29分";
        timeLabel.text = [self getHour:@"" systemTime:self.matchEndTime];
    [self.view addSubview:timeLabel];
    [timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(titleLabel.mas_bottom).offset(8);
        make.left.and.right.equalTo(self.view);
        make.height.mas_equalTo(scaleTopAndBottom(15));
    }];
    UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    backBtn.titleLabel.font = [UIFont systemFontOfSize:13];
    [backBtn addTarget:self action:@selector(backCenterPageView:) forControlEvents:UIControlEventTouchUpInside];
    [backBtn setTitle:@"返回首页" forState:UIControlStateNormal];
    [backBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    backBtn.layer.borderColor = [UIColor whiteColor].CGColor;
    backBtn.layer.borderWidth = 0.5;
    [topView addSubview:backBtn];
    [backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(topView.mas_centerX);
        make.top.equalTo(timeLabel.mas_bottom).offset(scaleTopAndBottom(19));
        make.size.mas_equalTo(CGSizeMake(scaleLeftAndRight(85), scaleTopAndBottom(30)));
    }];
    UIView *centerView = [[UIView alloc] init];
    centerView.backgroundColor = [UIColor whiteColor];
    [faterVeiw addSubview:centerView];
    [centerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(faterVeiw.mas_left).offset(scaleLeftAndRight(10));
        make.centerX.equalTo(faterVeiw.mas_centerX);
        make.top.equalTo(topView.mas_bottom).offset(scaleTopAndBottom(-154));
        make.height.mas_equalTo(scaleTopAndBottom(705));
    }];
    UILabel *centerViewTitleLabel = [[UILabel alloc] init];
    centerViewTitleLabel.textAlignment = NSTextAlignmentCenter;
    centerViewTitleLabel.text = @"赛事主题";
    centerViewTitleLabel.font = [UIFont fontWithName:@"PingFangSC-Semibold" size:16];
    if (WIDTH > 375.0f) {
        centerViewTitleLabel.font = [UIFont fontWithName:@"PingFangSC-Semibold" size:24];
    }
    if (WIDTH < 375.f) {
        centerViewTitleLabel.font = [UIFont fontWithName:@"PingFangSC-Semibold" size:11];
    }
    centerViewTitleLabel.textColor = COLOR_HEX(0x121212);
    [centerView addSubview:centerViewTitleLabel];
    [centerViewTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(centerView.mas_top).offset(scaleTopAndBottom(22));
        make.centerX.equalTo(centerView.mas_centerX);
        make.width.mas_equalTo(WIDTH);
        make.height.mas_equalTo(scaleTopAndBottom(15));
    }];
    UILabel *productLabel = [[UILabel alloc] init];
    productLabel.textAlignment = NSTextAlignmentCenter;
    productLabel.text = self.matchName;
    productLabel.font = [UIFont fontWithName:@"PingFangSC-Medium" size:15];
    if (WIDTH > 375.f) {
        productLabel.font = [UIFont fontWithName:@"PingFangSC-Medium" size:23];
    }
    if (WIDTH < 375.f) {
        productLabel.font = [UIFont fontWithName:@"PingFangSC-Medium" size:10];
    }
    productLabel.textColor = COLOR_HEX(0x666666);
    [centerView addSubview:productLabel];
    [productLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(centerView.mas_centerX);
        make.top.equalTo(centerViewTitleLabel.mas_bottom).offset(scaleTopAndBottom(12));
        make.height.mas_equalTo(scaleTopAndBottom(15));
    }];
    UIImageView *leftImageView = [[UIImageView alloc] init];
    leftImageView.image = [UIImage imageNamed:@"椭圆1"];
    [centerView addSubview:leftImageView];
    [leftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(productLabel.mas_left).offset(scaleLeftAndRight(-9));
        make.size.mas_equalTo(CGSizeMake(scaleLeftAndRight(17), scaleTopAndBottom(4)));
        make.centerY.mas_equalTo(productLabel.mas_centerY);
    }];
    leftImageView.transform = CGAffineTransformMakeRotation(M_PI);
    UIImageView *rightImageView = [[UIImageView alloc] init];
    rightImageView.image = [UIImage imageNamed:@"椭圆1"];
    [centerView addSubview:rightImageView];
    [rightImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(productLabel.mas_right).offset(scaleLeftAndRight(9));
        make.size.mas_equalTo(CGSizeMake(scaleLeftAndRight(17), scaleTopAndBottom(4)));
        make.centerY.mas_equalTo(productLabel.mas_centerY);
    }];
    UIImageView *lineImageView = [[UIImageView alloc] init];
    [centerView addSubview:lineImageView];
    [lineImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(centerView.mas_centerX);
        make.size.mas_equalTo(CGSizeMake(scaleLeftAndRight(248), scaleTopAndBottom(1)));
        make.top.equalTo(productLabel.mas_bottom).offset(scaleTopAndBottom(20));
    }];
    UIImageView *bgImageView = [[UIImageView alloc] init];
    [centerView addSubview:bgImageView];
    UIImageView *productView = [[UIImageView alloc] init];
    [bgImageView addSubview:productView];
    NSData *imgeData = [NSData dataWithContentsOfURL:[NSURL URLWithString:self.imgePath]];
    UIImage *image = [UIImage imageWithData:imgeData];
    if (image.size.height > image.size.width) {
        [bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(lineImageView.mas_bottom).offset(scaleTopAndBottom(20));
            make.size.mas_equalTo(CGSizeMake(scaleLeftAndRight(265), scaleTopAndBottom(317)));
            make.centerX.equalTo(centerView.mas_centerX).offset(scaleLeftAndRight(20));
        }];
        bgImageView.image = [UIImage imageNamed:@"phtoBg"];
        [productView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(scaleLeftAndRight(160), scaleTopAndBottom(220)));
            make.left.equalTo(bgImageView.mas_left).offset(scaleLeftAndRight(32.5));
            make.top.equalTo(bgImageView.mas_top).offset(scaleTopAndBottom(34.5));
        }];
    }else{
        bgImageView.image = [UIImage imageNamed:@"hengPhotoBg"];
        [bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(lineImageView.mas_bottom).offset(scaleTopAndBottom(20));
            make.size.mas_equalTo(CGSizeMake(scaleLeftAndRight(285), scaleTopAndBottom(238)));
            make.centerX.equalTo(centerView.mas_centerX).offset(scaleLeftAndRight(15));
        }];
        [productView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(scaleLeftAndRight(200), scaleTopAndBottom(145)));
            make.left.equalTo(bgImageView.mas_left).offset(scaleLeftAndRight(30));
            make.top.equalTo(bgImageView.mas_top).offset(scaleTopAndBottom(28));
        }];
    }


    [productView sd_setImageWithURL:[NSURL URLWithString:self.imgePath] placeholderImage:[UIImage imageNamed:@""]];
    UIImageView *banyuanView = [[UIImageView alloc] init];
    [centerView addSubview:banyuanView];
    [banyuanView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bgImageView.mas_bottom).offset(scaleTopAndBottom(15));
        make.centerX.equalTo(centerView.mas_centerX);
        make.left.equalTo(centerView.mas_left);
        make.height.mas_equalTo(scaleTopAndBottom(48));
    }];
    UIView *leftBanyuanView = [[UIView alloc] initWithFrame:CGRectMake(scaleLeftAndRight(-24), 0, scaleLeftAndRight(48), scaleTopAndBottom(48))];
    leftBanyuanView.backgroundColor = COLOR_HEX(0xf3f4f5);
    [banyuanView addSubview:leftBanyuanView];
    [leftBanyuanView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(scaleLeftAndRight(48), scaleTopAndBottom(48)));
        make.centerX.equalTo(banyuanView.mas_left);
        make.top.equalTo(banyuanView.mas_top);
    }];
    leftBanyuanView.layer.cornerRadius = scaleTopAndBottom(24);
    leftBanyuanView.layer.masksToBounds = YES;
    
    UIView *rightBanyuanView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, scaleLeftAndRight(48), scaleTopAndBottom(48))];
    rightBanyuanView.backgroundColor = COLOR_HEX(0xf3f4f5);
    [banyuanView addSubview:rightBanyuanView];
    [rightBanyuanView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(scaleLeftAndRight(48), scaleTopAndBottom(48)));
        make.centerX.equalTo(banyuanView.mas_right);
        make.top.equalTo(banyuanView.mas_top);
    }];
    rightBanyuanView.layer.cornerRadius = scaleTopAndBottom(24);
    rightBanyuanView.layer.masksToBounds = YES;
    
    UIImageView *centerLineLabel = [[UIImageView alloc] init];
    centerLineLabel.image = [UIImage imageNamed:@"形状1"];
    [banyuanView addSubview:centerLineLabel];
    [centerLineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(leftBanyuanView.mas_right).offset(scaleLeftAndRight(2));
        make.centerX.equalTo(banyuanView.mas_centerX);
        make.centerY.equalTo(banyuanView.mas_centerY);
        make.height.mas_equalTo(scaleTopAndBottom(1));
    }];
    UILabel *autorProductLabel = [[UILabel alloc] init];
    autorProductLabel.text = @"作品名称";
    autorProductLabel.font = [UIFont systemFontOfSize:14];
    [centerView addSubview:autorProductLabel];
    [autorProductLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(banyuanView.mas_bottom).offset(scaleTopAndBottom(30)); make.left.equalTo(centerView.mas_left).offset(scaleLeftAndRight(25));
        make.width.mas_equalTo(scaleLeftAndRight(120));
        make.height.mas_equalTo(scaleTopAndBottom(15));
    }];
    
    UILabel *autorProductLabel1 = [[UILabel alloc] init];
    autorProductLabel1.text = self.productName;
    autorProductLabel1.font = [UIFont systemFontOfSize:14];
    [centerView addSubview:autorProductLabel1];
    [autorProductLabel1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(banyuanView.mas_bottom).offset(scaleTopAndBottom(30)); make.left.equalTo(autorProductLabel.mas_right).offset(scaleLeftAndRight(30));
        make.right.equalTo(centerView.mas_right).offset(scaleLeftAndRight(-25));
        make.height.mas_equalTo(scaleTopAndBottom(15));
    }];
    
    
    UILabel *autorNameLabel = [[UILabel alloc] init];
    autorNameLabel.text = @"宝宝姓名";
    autorNameLabel.font = [UIFont systemFontOfSize:14];
    [centerView addSubview:autorNameLabel];
    [autorNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(autorProductLabel.mas_bottom).offset(scaleTopAndBottom(15)); make.left.equalTo(centerView.mas_left).offset(scaleLeftAndRight(25));
        make.width.mas_equalTo(scaleLeftAndRight(120));
        make.height.mas_equalTo(scaleTopAndBottom(15));
    }];
    UILabel *autorNameLabel1 = [[UILabel alloc] init];
    autorNameLabel1.text = self.babayName;
    autorNameLabel1.font = [UIFont systemFontOfSize:14];
    [centerView addSubview:autorNameLabel1];
    [autorNameLabel1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(autorProductLabel.mas_bottom).offset(scaleTopAndBottom(15)); make.left.equalTo(autorNameLabel.mas_right).offset(scaleLeftAndRight(30));
        make.right.equalTo(centerView.mas_right).offset(scaleLeftAndRight(-25));
        make.height.mas_equalTo(scaleTopAndBottom(15));
    }];
    
    UILabel *autorContactWayLabel = [[UILabel alloc] init];
    autorContactWayLabel.text = @"联系方式";
    autorContactWayLabel.font = [UIFont systemFontOfSize:14];
    [centerView addSubview:autorContactWayLabel];
    [autorContactWayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(autorNameLabel.mas_bottom).offset(scaleTopAndBottom(15)); make.left.equalTo(centerView.mas_left).offset(scaleLeftAndRight(25));
        make.width.mas_equalTo(scaleLeftAndRight(120));
        make.height.mas_equalTo(scaleTopAndBottom(15));
    }];
    
    UILabel *autorContactWayLabel1 = [[UILabel alloc] init];
    autorContactWayLabel1.text = self.phoneNumberStr;
    autorContactWayLabel1.font = [UIFont systemFontOfSize:14];
    [centerView addSubview:autorContactWayLabel1];
    [autorContactWayLabel1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(autorNameLabel.mas_bottom).offset(scaleTopAndBottom(15)); make.left.equalTo(autorContactWayLabel.mas_right).offset(scaleLeftAndRight(30));
        make.right.equalTo(centerView.mas_right).offset(scaleLeftAndRight(-25));
        make.height.mas_equalTo(scaleTopAndBottom(15));
    }];
    
    UILabel *autorAddressLabel = [[UILabel alloc] init];
    autorAddressLabel.text = self.matchTxt;
    autorAddressLabel.font = [UIFont systemFontOfSize:14];
    [centerView addSubview:autorAddressLabel];
    [autorAddressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(autorContactWayLabel.mas_bottom).offset(scaleTopAndBottom(15)); make.left.equalTo(autorContactWayLabel1.mas_left).offset(scaleLeftAndRight(0));
        make.right.equalTo(centerView.mas_right).offset(scaleLeftAndRight(-25));
        make.height.mas_equalTo(scaleTopAndBottom(30));
    }];
    UILabel * annotationLabel = [[UILabel alloc] init];
    annotationLabel.textColor = COLOR_HEX(0xFF5428);
    annotationLabel.font = [UIFont systemFontOfSize:12];
    annotationLabel.textAlignment = NSTextAlignmentCenter;
    annotationLabel.text = @"注释: 分享到第三方平台为作品投票，更容易获奖哦";
    [centerView addSubview:annotationLabel];
    [annotationLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(autorAddressLabel.mas_bottom).offset(scaleTopAndBottom(30));
        make.centerX.equalTo(centerView.mas_centerX);
        make.height.mas_equalTo(scaleTopAndBottom(15));
        make.width.mas_equalTo(WIDTH);
    }];
    UILabel *lastBottomLabel = [[UILabel alloc] init];
    lastBottomLabel.text = @"我是有底线的";
    lastBottomLabel.textColor = COLOR_HEX(0xB2B2B2);
    lastBottomLabel.textAlignment = NSTextAlignmentCenter;
    lastBottomLabel.font = [UIFont systemFontOfSize:10];
    NSDictionary *dic = @{NSFontAttributeName : [UIFont systemFontOfSize:10.f]};
    CGSize labelSize = [lastBottomLabel.text boundingRectWithSize:CGSizeMake(100, 100) options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading attributes:dic context:nil].size;
    [faterVeiw addSubview:lastBottomLabel];
    [lastBottomLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(faterVeiw.mas_centerX);
        make.bottom.equalTo(faterVeiw.mas_bottom).offset(scaleTopAndBottom(-17));
        make.top.equalTo(centerView.mas_bottom).offset(scaleTopAndBottom(17));
        make.width.mas_equalTo(scaleLeftAndRight(80));
    }];
    UIView *bottomLineLeftView = [[UIView alloc] init];
    bottomLineLeftView.backgroundColor = COLOR_HEX(0xDBDBDB);
    [faterVeiw addSubview:bottomLineLeftView];
    [bottomLineLeftView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(faterVeiw.mas_left).offset(scaleLeftAndRight(41));
        make.centerY.equalTo(lastBottomLabel.mas_centerY);
        make.right.equalTo(lastBottomLabel.mas_left).offset(scaleLeftAndRight(0));
        make.height.mas_equalTo(1);
    }];
    UIView *bottomLineRightView = [[UIView alloc] init];
    bottomLineRightView.backgroundColor = COLOR_HEX(0xDBDBDB);
    [faterVeiw addSubview:bottomLineRightView];
    [bottomLineRightView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(faterVeiw.mas_right).offset(scaleLeftAndRight(-41));
        make.centerY.equalTo(lastBottomLabel.mas_centerY);
        make.left.equalTo(lastBottomLabel.mas_right).offset(scaleLeftAndRight(0));
        make.height.mas_equalTo(1);
    }];
    if (@available(iOS 11.0, *)) {
        self.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    } else {
        // Fallback on earlier versions
    }

}
/**
 根据时间戳获取到时间差
 
 */
- (NSString* )getHour:(NSString *)takeCarTime systemTime:(NSString *)systemTime

{
    
    //  时区相差8个小时 加上这个时区即是北京时间
    
    NSTimeZone *timeZone = [NSTimeZone systemTimeZone];
    
    NSInteger delta = [timeZone secondsFromGMT];
    
    NSDate *DRstartDate = [NSDate date];
    NSDate *DRendDate = [[NSDate alloc] initWithTimeIntervalSince1970:[systemTime doubleValue]/1000 + delta];
    NSLog(@"开始时间%@",DRstartDate);
    NSLog(@"结束时间%@",DRendDate);
    // 日历对象 （方便比较两个日期之间的差距）
    
    NSTimeInterval interTime = [DRendDate timeIntervalSinceNow];
    //计算天数、时、分、秒
    
    int days = ((int)interTime)/(3600*24);
    
    int hours = ((int)interTime)%(3600*24)/3600;
    
    int minutes = ((int)interTime)%(3600*24)%3600/60;
    
    NSString *dateContent = [[NSString alloc] initWithFormat:@"倒计时:%i天%i时%i分",days,hours,minutes];
    NSLog(@"嘎嘎嘎嘎%@",dateContent);
    return dateContent;
    
}
-(void)getAllDataInformation{
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    NSString *sessionId = [[NSUserDefaults standardUserDefaults] objectForKey:@"sessionId"];
    NSDictionary *param = [NSDictionary dictionaryWithObjectsAndKeys:sessionId,@"sessionId",self.matchId,@"matchId", nil];
    NSString *url = ServerIp@"/matchApp/myMatchInfo";
    NSLog(@"请求参数%@",param);
    [manager POST:url parameters:param progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *jsonDic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
        NSDictionary *matchRecordDic = jsonDic[@"matchRecord"];
        self.phoneNumberStr = matchRecordDic[@"address"][@"phoneNumber"];
        self.babayName = matchRecordDic[@"babyName"];
        self.imgePath = matchRecordDic[@"file"][@"path"];
        self.productName = matchRecordDic[@"name"];
        self.matchName = matchRecordDic[@"match"][@"name"];
        self.matchEndTime = matchRecordDic[@"match"][@"matchEndTime"];
        self.matchTxt = matchRecordDic[@"txt"];
        NSLog(@"%@",jsonDic[@"msg"]);
         [self createNewPage];
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
    }];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
